<%@ page contentType="text/html" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%@ include file="header.jsp" %>
		<div id="halfRight">
			<h3>Active subscriptions</h3>
			<p>You are subscribed to the following rooms.</p>
			<p>Hurry, vote before the time runs out!</p>
			<c:forEach items="${subscriptions}" var="s">
				<p>
				<a href="../room/history?id=<c:out value="${s.room.id}"/>&error=0">
					<c:out value="${s.room.category.name}"/>
				</a>
				</p>
			</c:forEach>
		</div>

		<div id="halfLeft">
			<h3>Add Subscription</h3>
			<p>Add a new subscription to play</p>
			<%
				String subserror = (String)request.getAttribute("subscriptionerror");
				if(subserror != null){
				  %> <p class="ui-state-error"><%= subserror %></p> <%
				}
			%>
			<form action="add" method="post" class="botones">
				<p><label>Choose a category:</label></p>
				<select name="category" id="categoryCombo" onChange="getTime(this)">
				<c:forEach items="${categories}" var="c">
					<option value="<c:out value="${c.id}"/>">
						<c:out value="${c.name}"/>
					</option>
				</c:forEach>
				</select>
				<br/>
				<span id="categoryTime"></span>
				<p><label>Choose a question:</label></p>
				<select name="question">
				<c:forEach items="${questions}" var="q">
					<option value="<c:out value="${q.id}"/>">
						<c:out value="${q.question}"/> 
					</option>
				</c:forEach>
				</select>
				<br/>
				<input type="submit" value="Play now"/>
			</form>
		</div>
		
<script language="javascript" type="text/javascript" src="../../js/subscription.js"></script>		
<%@ include file="footer.jsp" %>